﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Text;
using System.Data;
using System.Collections;
using System.IO;
using Malu.Entity;
using Wicresoft.Framework.Organization;
using System.Data.OleDb;
using Wicresoft.Common;
using MaLu.Data;
using MaLu.Common;
using MaLu.BusiLogic;

namespace MaluJg.web.ProcessInput
{
    public partial class FSInputData : ImportPage
    {

        string fileName = "";
        string inputFileName = "";
        string inputOldFileName = "";
        Dictionary<string, string> dic = new Dictionary<string, string>();
        List<InputDataLog> OpLogList = new List<InputDataLog>();
        int record = 0;

        private string FormType
        {
            get
            {
                return Request["formtype"] ?? string.Empty;
            }

        }
        private int Year
        {
            get
            {
                int _year = 0;
                int.TryParse(Request["year"] ?? "0", out _year);
                if (_year == 0)
                    _year = DateTime.Today.Year;
                return _year;
            }

        }
        private DataTable DTVillage
        {
            get
            {
                if (ViewState["DTVillage"] == null)
                {
                    if (FormType.StartsWith("f"))

                        ViewState["DTVillage"] = BLFarm.GetFType(Provider);
                    else
                    {
                        ViewState["DTVillage"] = BLPoverty.GetFType(Provider);

                    }

                }
                return (DataTable)ViewState["DTVillage"];
            }
            set
            {

                ViewState["DTVillage"] = value;
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            string ids = string.Empty;

            UploadClass uc = new UploadClass();
            Session["UploadClass"] = uc;

            Page.Response.Cache.SetCacheability(HttpCacheability.NoCache);
            int status = 0;//状态
            string message = "";//反馈信息

            try
            {
                //检查文件
                if (Request.Files.Count == 0)
                {
                    status = 1;
                    message = "请先选择要上传的文件";
                    RenderUploadScript(status, message);
                }
                inputOldFileName = Request.Files[0].FileName;
                string ext = Path.GetExtension(Request.Files[0].FileName).ToLower();
                inputOldFileName = Path.GetFileName(inputOldFileName);
                string fileID = DateTime.Now.ToString("yyyyMMddHHmmss"); //Guid.NewGuid().ToString();
                fileName = Server.MapPath(String.Format(System.Configuration.ConfigurationManager.AppSettings["InputFile"] + "/{0}", fileID + ext));
                inputFileName = fileName;
                Request.Files[0].SaveAs(fileName);
                //记录到当前页面
                DoWork();
                RenderUploadScript(0, fileID + ext);
            }
            catch (Exception exc)
            { RenderUploadScript(1, exc.Message); }
        }

        private void RenderUploadScript(int status, string mess)
        {
            string script = string.Format("<script language='javascript'> window.parent.uploadImageResponse(\"{{ status:{0},message:'{1}'}}\"); </script>", status, mess);
            Response.Write(script);
        }


        #region 农民股金

        private void InsertFarmShare(System.Data.DataRow row)
        {
            UploadClass uc = (UploadClass)Session["UploadClass"];
            StringBuilder tempDesc = new StringBuilder();

            try
            {
                InputDataLog log = new InputDataLog();
                log.UserId = CurrentUser.ID;
                log.UserName = CurrentUser.Name;
                log.OpTime = DateTime.Now;
                log.InputDataType = "FarmShareInfo";
                log.FileName = Path.GetFileName(fileName);
                log.ErrType = DataInputErrType.FieldError.ToString();
                log.DataContent = tempDesc.ToString();
                log.ErrDesc = string.Empty;
                log.Status = DataInputErrStatus.Error.ToString();

                int _amount = 0;
                float _jinepergu = 0.0f;
                float _jine = 0.0f;
                float _honglipercent = 0.0f;
                float _yingde = 0.0f;
                float _fax = 0.0f;
                float _realget = 0.0f;


                string errStr = string.Empty;

                if (row["户名"].ToString().Trim() == string.Empty)
                {
                    errStr += "户名不能为空 ";
                }
                if (!int.TryParse(row["入股数"].ToString().Trim(), out _amount))
                {
                    errStr += "入股数数值有误 ";
                }
                if (!float.TryParse(row["每股金额"].ToString().Trim(), out _jinepergu))
                {
                    errStr += "每股金额数值有误 ";
                }
                if (!float.TryParse(row["入股金额"].ToString().Trim(), out _jine))
                {
                    errStr += "入股金额数值有误 ";
                }
                if (!float.TryParse(row["红利率"].ToString().Trim(), out _honglipercent))
                {
                    errStr += "红利率数值有误 ";
                }
                if (!float.TryParse(row["应得股息"].ToString().Trim(), out _yingde))
                {
                    errStr += "应得股息数值有误 ";
                }
                if (!float.TryParse(row["扣除股息税"].ToString().Trim(), out _fax))
                {
                    errStr += "扣除股息税数值有误 ";
                }
                if (!float.TryParse(row["实得股息"].ToString().Trim(), out _realget))
                {
                    errStr += "实得股息数值有误 ";
                }
                if (row["村"].ToString().Trim() == string.Empty)
                {
                    errStr += "村不能为空";
                }

                log.ErrDesc = errStr;
                record++;
                if (errStr != string.Empty)
                {
                    OpLogList.Add(log);
                    uc.ErrCount++;
                }
                else
                {
                    FaShare fs = new FaShare();
                    fs.amount = _amount;
                    fs.familyname = row["户名"].ToString().Trim();
                    fs.fax = _fax;
                    fs.honglipercent = _honglipercent;
                    fs.jine = _jine;
                    fs.jinepergu = _jinepergu;
                    fs.place = row["村民小组"].ToString().Trim();
                    fs.realget = _realget;
                    fs.yingde = _yingde;
                    fs.remark = string.Empty;
                    fs.village = row["村"].ToString().Trim();
                    fs.year = Year;
                    //string where = "where familyname =N'" + fs.familyname + "'";
                    //where += " and Village ='" + fs.village + "'";
                    //where += " and year ='" + fs.year + "'";
                    //int count = ProviderManager.Factory.FaShare.Count(Provider, where);

                    //if (count == 0)
                    ProviderManager.Factory.FaShare.Insert(Provider, fs);
                    //else
                    //{
                    //    log.ErrDesc =record+ " 重复";
                    //    OpLogList.Add(log);

                    //}
                    uc.RightCount++;
                }
            }
            catch (Exception exc)
            {
                uc.ErrDes = exc.Message;
            }
            Session["UploadClass"] = uc;
        }
        #endregion

        #region 摊位
        private void InsertBooth(System.Data.DataRow row)
        {
            UploadClass uc = (UploadClass)Session["UploadClass"];
            StringBuilder tempDesc = new StringBuilder();

            try
            {
                InputDataLog log = new InputDataLog();
                log.UserId = CurrentUser.ID;
                log.UserName = CurrentUser.Name;
                log.OpTime = DateTime.Now;
                log.InputDataType = "BoothInfo";
                log.FileName = Path.GetFileName(fileName);
                log.ErrType = DataInputErrType.FieldError.ToString();
                log.DataContent = tempDesc.ToString();
                log.ErrDesc = string.Empty;
                log.Status = DataInputErrStatus.Error.ToString();

                float butie = 0;
                int days = 0;
                int villageid = 0;
                DateTime dtime = DateTime.Today;

                string errStr = string.Empty;

                if (row["姓名"].ToString().Trim() == string.Empty)
                {
                    errStr += "姓名不能为空 ";
                }
                if (!float.TryParse(row["补贴金额(元)"].ToString().Trim(), out butie))
                {
                    errStr += "补贴金额(元) ";
                }
                if (!int.TryParse(row["租用摊位天数"].ToString().Trim(), out days))
                {
                    errStr += "租用摊位天数 ";
                }

                if (row["是否合作社社员"].ToString().Trim() != "是" && row["是否合作社社员"].ToString().Trim() != "否")
                {
                    errStr += "是否合作社社员必须为是或者否 ";
                }

                if (row["村"].ToString().Trim() == string.Empty)
                {
                    errStr += "村不能为空 ";
                }
                else
                {
                    DataRow[] drvillage = DTVillage.Select("name='" + row["村"].ToString().Trim() + "'");
                    if (drvillage.Length > 0)
                    {

                        villageid = int.Parse(drvillage[0]["id"].ToString());
                    }
                    else
                    {
                        errStr += "找不到对应的村 ";

                    }

                }

                log.ErrDesc = errStr;

                if (errStr != string.Empty)
                {
                    OpLogList.Add(log);
                    uc.ErrCount++;
                }
                else
                {
                    Booth boo = new Booth();


                    boo.familyname = row["姓名"].ToString().Trim();
                    boo.days = days;

                    boo.ispartner = row["是否合作社社员"].ToString() == "是";
                    boo.money = butie;
                    boo.rentperday = 20;
                    boo.villageid = villageid;
                    boo.year = Year;
                    string where = "where familyname =N'" + boo.familyname + "'";
                    where += " and VillageID ='" + boo.villageid + "'";
                    where += " and year ='" + boo.year + "'";
                    int count = ProviderManager.Factory.Booth.Count(Provider, where);
                    if (count == 0)
                        ProviderManager.Factory.Booth.Insert(Provider, boo);
                    uc.RightCount++;
                }
            }
            catch (Exception exc)
            {
                uc.ErrDes = exc.Message;
            }
            Session["UploadClass"] = uc;
        }
        #endregion

        #region 化肥
        private void InsertHuaFei(System.Data.DataRow row)
        {
            UploadClass uc = (UploadClass)Session["UploadClass"];
            StringBuilder tempDesc = new StringBuilder();

            try
            {
                InputDataLog log = new InputDataLog();
                log.UserId = CurrentUser.ID;
                log.UserName = CurrentUser.Name;
                log.OpTime = DateTime.Now;
                log.InputDataType = "HuaFeiInfo";
                log.FileName = Path.GetFileName(fileName);
                log.ErrType = DataInputErrType.FieldError.ToString();
                log.DataContent = tempDesc.ToString();
                log.ErrDesc = string.Empty;
                log.Status = DataInputErrStatus.Error.ToString();

                float butie = 0;
                float squares = 0;
                float book = 0;
                float heding = 0;
                int villageid = 0;
                DateTime dtime = DateTime.Today;

                string errStr = string.Empty;

                if (row["户名"].ToString().Trim() == string.Empty)
                {
                    errStr += "户名不能为空 ";
                }
                if (!float.TryParse(row["补贴金额(元)"].ToString().Trim(), out butie))
                {
                    errStr += "补贴金额(元)应为数值 ";
                }
                if (!float.TryParse(row["入社面积"].ToString().Trim(), out squares))
                {
                    errStr += "入社面积应为数值 ";
                }

                if (!float.TryParse(row["订购数量(吨)"].ToString().Trim(), out book))
                {
                    errStr += "订购数量(吨)应为数值  ";
                }
                if (!float.TryParse(row["核定补贴数量(吨)"].ToString().Trim(), out heding))
                {
                    errStr += "核定补贴数量(吨)应为数值  ";
                }
                if (row["村"].ToString().Trim() == string.Empty)
                {
                    errStr += "村不能为空 ";
                }
                else
                {
                    DataRow[] drvillage = DTVillage.Select("name='" + row["村"].ToString().Trim() + "'");
                    if (drvillage.Length > 0)
                    {

                        villageid = int.Parse(drvillage[0]["id"].ToString());
                    }
                    else
                    {
                        errStr += "找不到对应的村 ";

                    }

                }

                log.ErrDesc = errStr;

                if (errStr != string.Empty)
                {
                    OpLogList.Add(log);
                    uc.ErrCount++;
                }
                else
                {
                    Fertilizer fer = new Fertilizer();
                    fer.familyname = row["户名"].ToString().Trim();
                    fer.bianhao = row["合作社编号"].ToString().Trim();
                    fer.bookmount = book;
                    fer.money = butie;
                    fer.quota = heding;
                    fer.villageid = villageid;
                    fer.squares = squares;
                    fer.year = Year;
                    string where = "where familyname =N'" + fer.familyname + "'";
                    where += " and VillageID ='" + fer.villageid + "'";
                    where += " and year ='" + fer.year + "'";
                    int count = ProviderManager.Factory.Fertilizer.Count(Provider, where);
                    if (count == 0)
                        ProviderManager.Factory.Fertilizer.Insert(Provider, fer);
                    uc.RightCount++;
                }
            }
            catch (Exception exc)
            {
                uc.ErrDes = exc.Message;
            }
            Session["UploadClass"] = uc;

        }

        #endregion
        #region 冷库

        private void InsertCold(DataRow row)
        {
            UploadClass uc = (UploadClass)Session["UploadClass"];
            StringBuilder tempDesc = new StringBuilder();

            try
            {
                InputDataLog log = new InputDataLog();
                log.UserId = CurrentUser.ID;
                log.UserName = CurrentUser.Name;
                log.OpTime = DateTime.Now;
                log.InputDataType = "ColdInfo";
                log.FileName = Path.GetFileName(fileName);
                log.ErrType = DataInputErrType.FieldError.ToString();
                log.DataContent = tempDesc.ToString();
                log.ErrDesc = string.Empty;
                log.Status = DataInputErrStatus.Error.ToString();

                float butie = 0;
                int days = 0;
                float money = 0;
                int villageid = 0;
                DateTime dtime = DateTime.Today;

                string errStr = string.Empty;

                if (row["租户姓名"].ToString().Trim() == string.Empty)
                {
                    errStr += "租户姓名不能为空 ";
                }
                if (!float.TryParse(row["补贴总额(元)"].ToString().Trim(), out butie))
                {
                    errStr += "补贴总额(元)应为数值 ";
                }

                if (!float.TryParse(row["租金总额(元)"].ToString().Trim(), out money))
                {
                    errStr += "租金总额(元)应为数值 ";
                }

                if (!int.TryParse(row["冷库租用天数"].ToString().Trim(), out days))
                {
                    errStr += "冷库租用天数应为数值 ";
                }

                if (row["是否合作社社员"].ToString().Trim() != "是" && row["是否合作社社员"].ToString().Trim() != "否")
                {
                    errStr += "是否合作社社员必须为是或者否 ";
                }

                if (row["村别"].ToString().Trim() == string.Empty)
                {
                    errStr += "村别不能为空 ";
                }
                else
                {
                    DataRow[] drvillage = DTVillage.Select("name='" + row["村别"].ToString().Trim() + "'");
                    if (drvillage.Length > 0)
                    {

                        villageid = int.Parse(drvillage[0]["id"].ToString());
                    }
                    else
                    {
                        errStr += "找不到对应的村 ";

                    }

                }

                log.ErrDesc = errStr;

                if (errStr != string.Empty)
                {
                    OpLogList.Add(log);
                    uc.ErrCount++;
                }
                else
                {
                    Cold col = new Cold();


                    col.familyname = row["租户姓名"].ToString().Trim();
                    col.days = days;

                    col.ispartner = row["是否合作社社员"].ToString() == "是";
                    col.rent = butie;
                    col.rentperday = 20;
                    col.villageid = villageid;
                    col.year = Year;
                    string where = "where familyname =N'" + col.familyname + "'";
                    where += " and VillageID ='" + col.villageid + "'";
                    where += " and year ='" + col.year + "'";
                    int count = ProviderManager.Factory.Cold.Count(Provider, where);
                    if (count == 0)
                        ProviderManager.Factory.Cold.Insert(Provider, col);
                    uc.RightCount++;
                }
            }
            catch (Exception exc)
            {
                uc.ErrDes = exc.Message;
            }
            Session["UploadClass"] = uc;

        }
        #endregion
        #region 大棚
        private void InsertGreen(DataRow row)
        {
            UploadClass uc = (UploadClass)Session["UploadClass"];
            StringBuilder tempDesc = new StringBuilder();

            try
            {
                InputDataLog log = new InputDataLog();
                log.UserId = CurrentUser.ID;
                log.UserName = CurrentUser.Name;
                log.OpTime = DateTime.Now;
                log.InputDataType = "GreenInfo";
                log.FileName = Path.GetFileName(fileName);
                log.ErrType = DataInputErrType.FieldError.ToString();
                log.DataContent = tempDesc.ToString();
                log.ErrDesc = string.Empty;
                log.Status = DataInputErrStatus.Error.ToString();

                float butie = 0;
                float mues = 0;
                float squares = 0;
                
                int villageid = 0;
                DateTime dtime = DateTime.Today;

                string errStr = string.Empty;

                if (row["农户姓名"].ToString().Trim() == string.Empty)
                {
                    errStr += "农户姓名不能为空 ";
                }
                if (!float.TryParse(row["补贴金额(元)"].ToString().Trim(), out butie))
                {
                    errStr += "补贴金额(元)应为数值 ";
                }

                if (!float.TryParse(row["搭建面积(㎡)"].ToString().Trim(), out squares))
                {
                    errStr += "搭建面积(㎡)应为数值 ";
                }

                if (!float.TryParse(row["折合亩数(亩)"].ToString().Trim(), out mues))
                {
                    errStr += "折合亩数(亩)应为数值 ";
                }


                if (row["村别"].ToString().Trim() == string.Empty)
                {
                    errStr += "村别不能为空 ";
                }
                else
                {
                    DataRow[] drvillage = DTVillage.Select("name='" + row["村别"].ToString().Trim() + "'");
                    if (drvillage.Length > 0)
                    {

                        villageid = int.Parse(drvillage[0]["id"].ToString());
                    }
                    else
                    {
                        errStr += "找不到对应的村 ";

                    }

                }

                log.ErrDesc = errStr;

                if (errStr != string.Empty)
                {
                    OpLogList.Add(log);
                    uc.ErrCount++;
                }
                else
                {
                    Green gre = new Green();
                    gre.familyname = row["农户姓名"].ToString().Trim();
                    gre.squares = squares;
                    gre.bianhao = row["合作社编号"].ToString().Trim();
                    gre.money = butie;
                    gre.moneypermu = 6000;
                    gre.villageid = villageid;
                    gre.year = Year;
                    string where = "where familyname =N'" + gre.familyname + "'";
                    where += " and VillageID ='" + gre.villageid + "'";
                    where += " and year ='" + gre.year + "'";
                    int count = ProviderManager.Factory.Green.Count(Provider, where);
                    if (count == 0)
                        ProviderManager.Factory.Green.Insert(Provider, gre);
                    uc.RightCount++;
                }
            }
            catch (Exception exc)
            {
                uc.ErrDes = exc.Message;
            }
            Session["UploadClass"] = uc;

        }
        #endregion
        #region 银灰膜
        private void InsertMembrane(DataRow row)
        {
            UploadClass uc = (UploadClass)Session["UploadClass"];
            StringBuilder tempDesc = new StringBuilder();

            try
            {
                InputDataLog log = new InputDataLog();
                log.UserId = CurrentUser.ID;
                log.UserName = CurrentUser.Name;
                log.OpTime = DateTime.Now;
                log.InputDataType = "GreenInfo";
                log.FileName = Path.GetFileName(fileName);
                log.ErrType = DataInputErrType.FieldError.ToString();
                log.DataContent = tempDesc.ToString();
                log.ErrDesc = string.Empty;
                log.Status = DataInputErrStatus.Error.ToString();

                float butie = 0;
                float kilos = 0;
                float money = 0;
                int villageid = 0;
                DateTime dtime = DateTime.Today;

                string errStr = string.Empty;

                if (row["社员姓名"].ToString().Trim() == string.Empty)
                {
                    errStr += "社员姓名不能为空 ";
                }
                if (!float.TryParse(row["补贴金额(元)"].ToString().Trim(), out butie))
                {
                    errStr += "补贴金额(元)应为数值 ";
                }

                if (!float.TryParse(row["金额(元)"].ToString().Trim(), out money))
                {
                    errStr += "金额(元)应为数值 ";
                }

                if (!float.TryParse(row["购买银灰膜数量(公斤)"].ToString().Trim(), out kilos))
                {
                    errStr += "购买银灰膜数量(公斤)应为数值 ";
                }


                if (row["村别"].ToString().Trim() == string.Empty)
                {
                    errStr += "村别不能为空 ";
                }
                else
                {
                    DataRow[] drvillage = DTVillage.Select("name='" + row["村别"].ToString().Trim() + "'");
                    if (drvillage.Length > 0)
                    {

                        villageid = int.Parse(drvillage[0]["id"].ToString());
                    }
                    else
                    {
                        errStr += "找不到对应的村 ";

                    }

                }

                log.ErrDesc = errStr;

                if (errStr != string.Empty)
                {
                    OpLogList.Add(log);
                    uc.ErrCount++;
                }
                else
                {
                    Membrane mem = new Membrane();
                    mem.familyname = row["社员姓名"].ToString().Trim();
                    mem.kilos = kilos;
                    mem.money = butie;
                    mem.moneyperkilo = 16;
                    mem.villageid = villageid;
                    mem.year = Year;
                    string where = "where familyname =N'" + mem.familyname + "'";
                    where += " and VillageID ='" + mem.villageid + "'";
                    where += " and year ='" + mem.year + "'";
                    int count = ProviderManager.Factory.Membrane.Count(Provider, where);
                    if (count == 0)
                        ProviderManager.Factory.Membrane.Insert(Provider, mem);
                    uc.RightCount++;
                }
            }
            catch (Exception exc)
            {
                uc.ErrDes = exc.Message;
            }
            Session["UploadClass"] = uc;
        }
        #endregion
        #region 包装箱
        
       
        private void InsertPackage(DataRow row)
        {
            UploadClass uc = (UploadClass)Session["UploadClass"];
            StringBuilder tempDesc = new StringBuilder();

            try
            {
                InputDataLog log = new InputDataLog();
                log.UserId = CurrentUser.ID;
                log.UserName = CurrentUser.Name;
                log.OpTime = DateTime.Now;
                log.InputDataType = "PackageInfo";
                log.FileName = Path.GetFileName(fileName);
                log.ErrType = DataInputErrType.FieldError.ToString();
                log.DataContent = tempDesc.ToString();
                log.ErrDesc = string.Empty;
                log.Status = DataInputErrStatus.Error.ToString();

                float butie = 0;
                float squares = 0;
                float f5 =float.MinValue;
                float f8 = float.MinValue;
                float f33 = 0;
                float heji = 0;
                int heding = 0;
                int villageid = 0;
                DateTime dtime = DateTime.Today;

                string errStr = string.Empty;

                if (row["姓名"].ToString().Trim() == string.Empty)
                {
                    errStr += "姓名不能为空 ";
                }
                if (!float.TryParse(row["补贴金额(元)"].ToString().Trim(), out butie))
                {
                    errStr += "补贴金额(元)应为数值 ";
                }

                if (!float.TryParse(row["入社面积"].ToString().Trim(), out squares))
                {
                    errStr += "入社面积应为数值 ";
                }
                if(row["5斤装"].ToString().Trim()!=string.Empty)
                if (!float.TryParse(row["5斤装"].ToString().Trim(), out f5))
                {
                    errStr += "5斤装应为数值 ";
                }
                if (row["8斤装"].ToString().Trim() != string.Empty)
                if (!float.TryParse(row["8斤装"].ToString().Trim(), out f8))
                {
                    errStr += "8斤装应为数值 ";
                }
                if (row["3+3礼盒"].ToString().Trim() != string.Empty)
                if (!float.TryParse(row["3+3礼盒"].ToString().Trim(), out f33))
                {
                    errStr += "3+3礼盒应为数值 ";
                }
                if (!float.TryParse(row["合计"].ToString().Trim(), out heji))
                {
                    errStr += "合计应为数值 ";
                }

                if (!int.TryParse(row["核定补贴盒子数量"].ToString().Trim(), out heding))
                {
                    errStr += "核定补贴盒子数量应为数值 ";
                }



                if (row["村别"].ToString().Trim() == string.Empty)
                {
                    errStr += "村别不能为空 ";
                }
                else
                {
                    DataRow[] drvillage = DTVillage.Select("name='" + row["村别"].ToString().Trim() + "'");
                    if (drvillage.Length > 0)
                    {

                        villageid = int.Parse(drvillage[0]["id"].ToString());
                    }
                    else
                    {
                        errStr += "找不到对应的村 ";

                    }

                }

                log.ErrDesc = errStr;

                if (errStr != string.Empty)
                {
                    OpLogList.Add(log);
                    uc.ErrCount++;
                }
                else
                {
                    Package pac = new Package();
                    pac.familyname = row["姓名"].ToString().Trim();
                    pac.bianhao = row["合作社编号"].ToString().Trim();
                    pac.money = butie;
                    pac.eight = f8;
                    pac.Five = f5;
                    pac.squares = squares;
                    pac.threeandthree = f33;
                    pac.validatedmount = heding;
                    pac.villageid = villageid;
                    pac.year = Year;
                    string where = "where familyname =N'" + pac.familyname + "'";
                    where += " and VillageID ='" + pac.villageid + "'";
                    where += " and year ='" + pac.year + "'";
                    int count = ProviderManager.Factory.Package.Count(Provider, where);
                    if (count == 0)
                        ProviderManager.Factory.Package.Insert(Provider, pac);
                    uc.RightCount++;
                }
            }
            catch (Exception exc)
            {
                uc.ErrDes = exc.Message;
            }
            Session["UploadClass"] = uc;
        }
        #endregion

        #region 低保
        private void InsertLiving(DataRow row)
        {
            UploadClass uc = (UploadClass)Session["UploadClass"];
            StringBuilder tempDesc = new StringBuilder();

            
            try
            {
                InputDataLog log = new InputDataLog();
                log.UserId = CurrentUser.ID;
                log.UserName = CurrentUser.Name;
                log.OpTime = DateTime.Now;
                log.InputDataType = "LivingInfo";
                log.FileName = Path.GetFileName(fileName);
                log.ErrType = DataInputErrType.FieldError.ToString();
                log.DataContent = tempDesc.ToString();
                log.ErrDesc = string.Empty;
                log.Status = DataInputErrStatus.Error.ToString();

                int villageid = 0;
                float town = 0.0f;
                int pCount = 0; 
                float district = 0.0f;
                string village = row["村"].ToString().Trim();
                DateTime dtime = DateTime.Today;

                string errStr = string.Empty;

                if (row["户主姓名"].ToString().Trim() == string.Empty)
                {
                    errStr += "户主姓名不能为空 ";
                }
                if (row["性别"].ToString().Trim() != "男" && row["性别"].ToString().Trim()!="女")
                {
                    errStr += "性别应为男或女 ";
                }
                if (row["类型"].ToString().Trim() != "农村" && row["类型"].ToString().Trim() != "城镇")
                {
                    errStr += "类型应为农村或城镇 ";
                }
                if (row["半年"].ToString().Trim() != "下半年" && row["半年"].ToString().Trim() != "上半年")
                {
                    errStr += "半年应为下半年或上半年 ";
                }
               
                if (!float.TryParse(row["区级救助"].ToString().Trim(), out district))
                {
                    errStr += "区级救助应为数值 ";
                }
              
                if (!float.TryParse(row["镇级救助"].ToString().Trim(), out town))
                {
                    errStr += "镇级救助应为数值 ";
                }
              
                if (row["低保覆盖人数"].ToString().Trim() != string.Empty)
                    if (!int.TryParse(row["低保覆盖人数"].ToString().Trim(), out pCount))
                {
                    errStr += "低保覆盖人数应为数值 ";
                }               

                if (row["村"].ToString().Trim() == string.Empty)
                {
                    errStr += "村不能为空 ";
                }
                else
                {
                    DataRow[] drvillage = DTVillage.Select("name='" + row["村"].ToString().Trim() + "'");
                    if (drvillage.Length > 0)
                    {

                        villageid = int.Parse(drvillage[0]["id"].ToString());
                    }
                    else
                    {
                        errStr += "找不到对应的村 ";
                    }
                }

                log.ErrDesc = errStr;

                if (errStr != string.Empty)
                {
                    OpLogList.Add(log);
                    uc.ErrCount++;
                }
                else
                {
                    Living liv = new Living();
                    liv.account= row["邮政储蓄卡账号"].ToString().Trim();
                    liv.address = row["家庭地址"].ToString().Trim();
                    liv.belongto = village;
                    liv.District = district;
                    liv.gender = row["性别"].ToString().Trim();
                    liv.halfyear = row["半年"].ToString().Trim() == "上半年"?1:0;
                    liv.money = district + town;
                    liv.name = row["户主姓名"].ToString().Trim();
                    liv.peoplecount = pCount;
                    liv.remark = row["备注"].ToString().Trim();
                    liv.Town = town;
                    liv.type = row["类型"].ToString().Trim();
                    liv.villagename = village;
                    liv.year = Year;                    
                    
                    string where = "where name =N'" + liv.name + "'";
                    where += " and Belongto ='" + liv.belongto + "'";
                    where += " and year ='" + liv.year + "'";
                    int count = ProviderManager.Factory.Live.Count(Provider, where);
                    if (count == 0)
                        ProviderManager.Factory.Live.Insert(Provider, liv);
                    uc.RightCount++;
                }
            }
            catch (Exception exc)
            {
                uc.ErrDes = exc.Message;
            }
            Session["UploadClass"] = uc;
        }
        #endregion
        #region 大病
        private void InsertSick(DataRow row)
        {
            UploadClass uc = (UploadClass)Session["UploadClass"];
            StringBuilder tempDesc = new StringBuilder();


            try
            {
                InputDataLog log = new InputDataLog();
                log.UserId = CurrentUser.ID;
                log.UserName = CurrentUser.Name;
                log.OpTime = DateTime.Now;
                log.InputDataType = "LivingInfo";
                log.FileName = Path.GetFileName(fileName);
                log.ErrType = DataInputErrType.FieldError.ToString();
                log.DataContent = tempDesc.ToString();
                log.ErrDesc = string.Empty;
                log.Status = DataInputErrStatus.Error.ToString();

                int villageid = 0;
                float town = 0.0f;               
                float apply = 0.0f;
                int month = 1;
                int age = 0;
                float district = 0.0f;
                string village = row["村"].ToString().Trim();
                DateTime dtime = DateTime.Today;

                string errStr = string.Empty;

                if (row["姓名"].ToString().Trim() == string.Empty)
                {
                    errStr += "姓名不能为空 ";
                }
                if (row["性别"].ToString().Trim() != "男" && row["性别"].ToString().Trim() != "女")
                {
                    errStr += "性别应为男或女 ";
                }
                if (row["类型"].ToString().Trim() != "农村" && row["类型"].ToString().Trim() != "城镇")
                {
                    errStr += "类型应为农村或城镇 ";
                }
              
                if (!float.TryParse(row["区级救助"].ToString().Trim(), out district))
                {
                    errStr += "区级救助应为数值 ";
                }

                if (!float.TryParse(row["镇级救助"].ToString().Trim(), out town))
                {
                    errStr += "镇级救助应为数值 ";
                }
                if (!int.TryParse(row["月份"].ToString().Trim(), out month))
                {
                    errStr += "月份应为数值 ";
                }
                if (!float.TryParse(row["申请金额"].ToString().Trim(), out apply))
                {
                    errStr += "申请金额应为数值 ";
                }
                if (row["年龄"].ToString().Trim() != string.Empty)
                    if (!int.TryParse(row["年龄"].ToString().Trim(), out age))
                    {
                        errStr += "年龄应为数值 ";
                    }

                if (row["村"].ToString().Trim() == string.Empty)
                {
                    errStr += "村不能为空 ";
                }
                else
                {
                    DataRow[] drvillage = DTVillage.Select("name='" + row["村"].ToString().Trim() + "'");
                    if (drvillage.Length > 0)
                    {

                        villageid = int.Parse(drvillage[0]["id"].ToString());
                    }
                    else
                    {
                        errStr += "找不到对应的村 ";
                    }
                }

                log.ErrDesc = errStr;

                if (errStr != string.Empty)
                {
                    OpLogList.Add(log);
                    uc.ErrCount++;
                }
                else
                {
                    Sicking sic = new Sicking();
                    sic.age = age;
                    sic.appliedmoney = apply;                  
                    sic.belongto = village;
                    sic.districtmoney = district;
                    sic.gender = row["性别"].ToString().Trim();
                    sic.month=month;
                    sic.money = district + town;
                    sic.name = row["姓名"].ToString().Trim();
                    sic.dept = row["所属单位"].ToString().Trim();
                    sic.sickname = row["疾病名称"].ToString().Trim();
                    sic.townmoney = town;
                

                    sic.IsTownFamliy = row["家庭类型"].ToString().Trim() == "城镇低收入"?"是":"否";
                    sic.IsTownMedical = row["医保情况"].ToString().Trim() == "城镇医保" ? "是" : "否";
                    sic.IsVillageFamliy = row["家庭类型"].ToString().Trim() == "农村低收入" ? "是" : "否";
                    sic.IsVillageMedical = row["医保情况"].ToString().Trim() == "合作医疗" ? "是" : "否";
                  
                    sic.year = Year;

                    string where = "where name =N'" + sic.name + "'";
                    where += " and Belongto ='" + sic.belongto + "'";
                    where += " and year ='" + sic.year + "'";
                    int count = ProviderManager.Factory.Sick.Count(Provider, where);
                    if (count == 0)
                        ProviderManager.Factory.Sick.Insert(Provider, sic);
                    uc.RightCount++;
                }
            }
            catch (Exception exc)
            {
                uc.ErrDes = exc.Message;
            }
            Session["UploadClass"] = uc;
        }

        #endregion
        #region 助学救助
        private void InsertStudy(DataRow row)
        {

            UploadClass uc = (UploadClass)Session["UploadClass"];
            StringBuilder tempDesc = new StringBuilder();


            try
            {
                InputDataLog log = new InputDataLog();
                log.UserId = CurrentUser.ID;
                log.UserName = CurrentUser.Name;
                log.OpTime = DateTime.Now;
                log.InputDataType = "StudyInfo";
                log.FileName = Path.GetFileName(fileName);
                log.ErrType = DataInputErrType.FieldError.ToString();
                log.DataContent = tempDesc.ToString();
                log.ErrDesc = string.Empty;
                log.Status = DataInputErrStatus.Error.ToString();

                int villageid = 0;               
                      
                float district = 0.0f;
                string village = row["村"].ToString().Trim();
                DateTime dtime = DateTime.Today;

                string errStr = string.Empty;

                if (row["户主姓名"].ToString().Trim() == string.Empty)
                {
                    errStr += "户主姓名不能为空 ";
                }
                if (row["学生姓名"].ToString().Trim() == string.Empty)
                {
                    errStr += "学生姓名不能为空 ";
                }

                if (row["性别"].ToString().Trim() != "男" && row["性别"].ToString().Trim() != "女")
                {
                    errStr += "性别应为男或女 ";
                }
                if (row["户籍性质"].ToString().Trim() != "农村" && row["户籍性质"].ToString().Trim() != "城镇")
                {
                    errStr += "户籍性质应为农村或城镇 ";
                }

                if (!float.TryParse(row["助学金额"].ToString().Trim(), out district))
                {
                    errStr += "助学金额应为数值 ";
                }

                if (row["半年"].ToString().Trim() != "下半年" && row["半年"].ToString().Trim() != "上半年")
                {
                    errStr += "半年应为下半年或上半年 ";
                }

                if (row["村"].ToString().Trim() == string.Empty)
                {
                    errStr += "村不能为空 ";
                }
                else
                {
                    DataRow[] drvillage = DTVillage.Select("name='" + row["村"].ToString().Trim() + "'");
                    if (drvillage.Length > 0)
                    {

                        villageid = int.Parse(drvillage[0]["id"].ToString());
                    }
                    else
                    {
                        errStr += "找不到对应的村 ";
                    }
                }

                log.ErrDesc = errStr;

                if (errStr != string.Empty)
                {
                    OpLogList.Add(log);
                    uc.ErrCount++;
                }
                else
                {
                    Study stu = new Study();
                    stu.address = row["家庭地址"].ToString().Trim();
                    stu.belongto = village;
                    stu.gender = row["性别"].ToString().Trim();
                    stu.halfyear = row["半年"].ToString().Trim() == "上半年" ? 1 : 0;
                    stu.money = district;
                    stu.household = row["户籍性质"].ToString().Trim();
                    stu.idnum = row["身份证号码"].ToString().Trim();                 
                    stu.name = row["户主姓名"].ToString().Trim();
                    stu.school = row["就读学校"].ToString().Trim();
                    stu.studentname = row["学生姓名"].ToString().Trim();                 
                    stu.year = Year;

                    string where = "where name =N'" + stu.name + "'";
                    where += " and Belongto ='" + stu.belongto + "'";
                    where += " and year ='" + stu.year + "'";
                    int count = ProviderManager.Factory.Study.Count(Provider, where);
                    if (count == 0)
                        ProviderManager.Factory.Study.Insert(Provider, stu);
                    uc.RightCount++;
                }
            }
            catch (Exception exc)
            {
                uc.ErrDes = exc.Message;
            }
            Session["UploadClass"] = uc;
        }
        #endregion
        #region 重残
        private void InsertDeformity(DataRow row)
        {
            UploadClass uc = (UploadClass)Session["UploadClass"];
            StringBuilder tempDesc = new StringBuilder();


            try
            {
                InputDataLog log = new InputDataLog();
                log.UserId = CurrentUser.ID;
                log.UserName = CurrentUser.Name;
                log.OpTime = DateTime.Now;
                log.InputDataType = "DeformityInfo";
                log.FileName = Path.GetFileName(fileName);
                log.ErrType = DataInputErrType.FieldError.ToString();
                log.DataContent = tempDesc.ToString();
                log.ErrDesc = string.Empty;
                log.Status = DataInputErrStatus.Error.ToString();

                int villageid = 0;
                float town = 0.0f;
                int pCount = 0;
                int month = 0;
                float monthmoney = 0.0f;
                float district = 0.0f;
                string village = row["村"].ToString().Trim();
                DateTime dtime = DateTime.Today;

                string errStr = string.Empty;

                if (row["姓名"].ToString().Trim() == string.Empty)
                {
                    errStr += "姓名不能为空 ";
                }
                if (row["性别"].ToString().Trim() != "男" && row["性别"].ToString().Trim() != "女")
                {
                    errStr += "性别应为男或女 ";
                }
                if (row["重残无业类型"].ToString().Trim() != "农村" && row["重残无业类型"].ToString().Trim() != "城镇")
                {
                    errStr += "类型应为农村或城镇 ";
                }
                if (!int.TryParse(row["月份"].ToString().Trim(), out month))
                {
                    errStr += "月份应为数值 ";
                }

                if (row["月份生活补贴"].ToString().Trim() != string.Empty)
                    if (!float.TryParse(row["月份生活补贴"].ToString().Trim(), out monthmoney))
                    {
                        errStr += "月份生活补贴应为数值 ";
                    }

                if (!float.TryParse(row["区级救助"].ToString().Trim(), out district))
                {
                    errStr += "区级救助应为数值 ";
                }

                if (!float.TryParse(row["镇级救助"].ToString().Trim(), out town))
                {
                    errStr += "镇级救助应为数值 ";
                }

                if (row["人数"].ToString().Trim() != string.Empty)
                    if (!int.TryParse(row["人数"].ToString().Trim(), out pCount))
                    {
                        errStr += "人数应为数值 ";
                    }

                if (row["村"].ToString().Trim() == string.Empty)
                {
                    errStr += "村不能为空 ";
                }
                else
                {
                    DataRow[] drvillage = DTVillage.Select("name='" + row["村"].ToString().Trim() + "'");
                    if (drvillage.Length > 0)
                    {

                        villageid = int.Parse(drvillage[0]["id"].ToString());
                    }
                    else
                    {
                        errStr += "找不到对应的村 ";
                    }
                }

                log.ErrDesc = errStr;

                if (errStr != string.Empty)
                {
                    OpLogList.Add(log);
                    uc.ErrCount++;
                }
                else
                {
                    Deformity dem = new Deformity();
                    dem.account = row["储蓄卡账号"].ToString().Trim();
                    dem.address = row["家庭地址"].ToString().Trim();
                    dem.belongto = village;
                    dem.District = district;
                    dem.gender = row["性别"].ToString().Trim();
                  
                    dem.money = district + town+monthmoney;
                    dem.name = row["姓名"].ToString().Trim();
                    dem.peoplecount = pCount;
                    dem.remark = row["备注"].ToString().Trim();
                    dem.Town = town;
                    dem.type = row["重残无业类型"].ToString().Trim();
                    dem.deformitynum =row["残疾证号"].ToString().Trim();
                    dem.deformitytype = row["残疾类别"].ToString().Trim();
                    dem.monthmoney = monthmoney;
                    dem.year = Year;
                    dem.month = month;

                    string where = "where name =N'" + dem.name + "'";
                    where += " and Belongto ='" + dem.belongto + "'";
                    where += " and year ='" + dem.year + "'";
                    int count = ProviderManager.Factory.Deformity.Count(Provider, where);
                    if (count == 0)
                        ProviderManager.Factory.Deformity.Insert(Provider, dem);
                    uc.RightCount++;
                }
            }
            catch (Exception exc)
            {
                uc.ErrDes = exc.Message;
            }
            Session["UploadClass"] = uc;
        }
        #endregion
        #region 其他
        private void InsertOther(DataRow row)
        {
            UploadClass uc = (UploadClass)Session["UploadClass"];
            StringBuilder tempDesc = new StringBuilder();


            try
            {
                InputDataLog log = new InputDataLog();
                log.UserId = CurrentUser.ID;
                log.UserName = CurrentUser.Name;
                log.OpTime = DateTime.Now;
                log.InputDataType = "OtherInfo";
                log.FileName = Path.GetFileName(fileName);
                log.ErrType = DataInputErrType.FieldError.ToString();
                log.DataContent = tempDesc.ToString();
                log.ErrDesc = string.Empty;
                log.Status = DataInputErrStatus.Error.ToString();

                int villageid = 0;
                float town = 0.0f;
                int pCount = 0;
                int month = 0;
               
                int male=0; int female=0;
                string village = row["村"].ToString().Trim();
                DateTime dtime = DateTime.Today;

                string errStr = string.Empty;

                if (row["姓名"].ToString().Trim() == string.Empty)
                {
                    errStr += "姓名不能为空 ";
                }
               
              

                if (!float.TryParse(row["镇补数"].ToString().Trim(), out town))
                {
                    errStr += "镇补数应为数值 ";
                }

                if (row["家庭中党员人数"].ToString().Trim() != string.Empty)
                    if (!int.TryParse(row["家庭中党员人数"].ToString().Trim(), out pCount))
                    {
                        errStr += "家庭中党员人数应为数值 ";
                    }

              
                if (row["男人数"].ToString().Trim() != string.Empty)
                    if (!int.TryParse(row["男人数"].ToString().Trim(), out male))
                    {
                        errStr += "男人数应为数值 ";
                    }

                if (!int.TryParse(row["月份"].ToString().Trim(), out month))
                {
                    errStr += "月份应为数值 ";
                }
               
                if (row["女人数"].ToString().Trim() != string.Empty)
                    if (!int.TryParse(row["女人数"].ToString().Trim(), out female))
                    {
                        errStr += "女人数应为数值 ";
                    }
                if (row["村"].ToString().Trim() == string.Empty)
                {
                    errStr += "村不能为空 ";
                }
                else
                {
                    DataRow[] drvillage = DTVillage.Select("name='" + row["村"].ToString().Trim() + "'");
                    if (drvillage.Length > 0)
                    {

                        villageid = int.Parse(drvillage[0]["id"].ToString());
                    }
                    else
                    {
                        errStr += "找不到对应的村 ";
                    }
                }

                log.ErrDesc = errStr;

                if (errStr != string.Empty)
                {
                    OpLogList.Add(log);
                    uc.ErrCount++;
                }
                else
                {
                    Others oth = new Others();
                  
                    oth.address = row["家庭地址"].ToString().Trim();
                    oth.belongto = village;
                    oth.money =  town ;
                    oth.name = row["姓名"].ToString().Trim();
                    oth.partycount = pCount;
                    oth.Reason = string.Empty;
                    oth.Town = town;
                    oth.Female = female;
                    oth.Male = male;
                    oth.year = Year;
                    oth.month = month;

                    string where = "where name =N'" + oth.name + "'";
                    where += " and Belongto ='" + oth.belongto + "'";
                    where += " and year ='" + oth.year + "'";
                    int count = ProviderManager.Factory.Other.Count(Provider, where);
                    if (count == 0)
                        ProviderManager.Factory.Other.Insert(Provider, oth);
                    uc.RightCount++;
                }
            }
            catch (Exception exc)
            {
                uc.ErrDes = exc.Message;
            }
            Session["UploadClass"] = uc;
        }
        #endregion
        /// <summary> 
        /// 读取一个XLSW文件并显示出来 
        /// </summary> 
        public void ReadExcel()
        {
            UploadClass uc = (UploadClass)Session["UploadClass"];

            try
            {
                string oleconn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + fileName + ";Extended Properties='Excel 8.0;HDR=YES'";
                //  HDR=NO　即无字段 
                //   HDR=yes　即有字段，一般默认excel表中第1行的列标题为字段名，如姓名、年龄等 
                //如果您在连接字符串中指定 HDR=NO，Jet OLE DB 提供程序将自动为您命名字段（F1 表示第一个字段，F2 表示第二个字段，依此类推）； 
                // IMEX　表示是否强制转换为文本 
                //   Excel 驱动程序读取指定源中一定数量的行（默认情况下为 8 行）以推测每列的数据类型。 
                //如果推测出列可能包含混合数据类型（尤其是混合了文本数据的数值数据时）， 
                //驱动程序将决定采用占多数的数据类型，并对包含其他类型数据的单元返回空值。 
                //（如果各种数据类型的数量相当，则采用数值类型。） 
                //Excel 工作表中大部分单元格格式设置选项不会影响此数据类型判断。 
                //可以通过指定导入模式来修改 Excel 驱动程序的此行为。 
                //若要指定导入模式，请在“属性”窗口中将 IMEX=1 添加到 Excel 
                //连接管理器的连接字符串内的扩展属性值中。

                OleDbConnection conn = new OleDbConnection(oleconn);
                conn.Open();
                string str_sql = "select * from [Sheet1$]";
                OleDbDataAdapter oda = new OleDbDataAdapter(str_sql, conn);
                DataSet ds = new DataSet();
                oda.Fill(ds);
                if (ds.Tables.Count > 0)
                {
                    System.Data.DataTable dt = ds.Tables[0];
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        System.Data.DataRow row = dt.Rows[i];

                        switch (FormType)
                        {
                            case "fshare": InsertFarmShare(row);
                                break;
                            case "fbooth": InsertBooth(row);
                                break;
                            case "fhuafei": InsertHuaFei(row);
                                break;
                            case "fcold": InsertCold(row);
                                break;
                            case "fgreen": InsertGreen(row);
                                break;
                            case "fmembrane": InsertMembrane(row);
                                break;
                            case "fpackage": InsertPackage(row);
                                break;
                            case "sliving": InsertLiving(row);
                                break;
                            case "ssick": InsertSick(row);
                                break;
                            case "sstudy": InsertStudy(row);
                                break;
                            case "sdeformity": InsertDeformity(row);
                                break;
                            case "sothers": InsertOther(row);
                                break;  
                            default: break;

                        }

                        uc.CompletePercentage = 100 * (i + 1) / dt.Rows.Count;
                    }
                    uc.CompletePercentage = 1;
                }
                conn.Close();
                if (OpLogList.Count > 0)
                {
                    uc.OpLogList = OpLogList;
                    string fileID = DateTime.Now.ToString("yyyyMMddHHmmss"); //Guid.NewGuid().ToString();
                    fileName = Server.MapPath(String.Format(System.Configuration.ConfigurationManager.AppSettings["InputLog"] + "/{0}", fileID + ".txt"));
                    FileStream file = new FileStream(fileName, FileMode.Create);
                    StreamWriter writer = new StreamWriter(file, System.Text.Encoding.GetEncoding("gb2312"));
                    string err = string.Empty;
                    foreach (InputDataLog log in OpLogList)
                    {
                        err = TransferStatus(log.ErrType);
                        if (!err.EndsWith("成功"))
                        {
                            StringBuilder des = new StringBuilder();
                            des.Append(string.Format(" {0}:[{1}]", "记录内容", log.DataContent));
                            des.Append(string.Format(" {0}:[{1}]", "异常原因", ((log.ErrDesc == "") ? "无" : log.ErrDesc)));
                            writer.WriteLine(des.ToString());
                        }
                    }
                    writer.Close();
                    writer.Dispose();
                    file.Close();
                    file.Dispose();

                    InputDataFileLog fileLog = new InputDataFileLog();
                    fileLog.totalcount = uc.RightCount + uc.ErrCount;
                    fileLog.successcount = uc.RightCount;
                    fileLog.failcount = uc.ErrCount;
                    fileLog.optime = DateTime.Now;
                    fileLog.logfilename = Path.GetFileName(fileName);
                    fileLog.inputfilename = Path.GetFileName(inputFileName);
                    fileLog.inputoldfilename = inputOldFileName;
                    fileLog.userid = CurrentUser.ID;
                    fileLog.username = CurrentUser.Name;
                    fileLog.userdisplayname = CurrentUser.DisplayName;
                    fileLog.inputdatatype = MaLu.Common.Const.InputDataType.Employee.ToString();

                    ProviderManager.Factory.InputDataFileLog.Insert(Provider, fileLog);


                }
            }
            catch (Exception exc)
            {
                uc.ErrDes = exc.Message;
            }
            Session["UploadClass"] = uc;
        }


        private string TransferStatus(string stutas)
        {
            string result = "";
            switch (DataInputErrTypeConvertor.String2T(stutas, true))
            {
                case DataInputErrType.Duplicate:
                    result = "记录重复";
                    break;
                case DataInputErrType.Insert_Error:
                    result = "上传错误";
                    break;
                case DataInputErrType.Insert_Success:
                    result = "上传成功";
                    break;
                case DataInputErrType.Edit_Success:
                    result = "修改成功";
                    break;

            }
            return result;
        }

        private void DoWork()
        {
            UploadClass uc = new UploadClass();
            Session["UploadClass"] = uc;
            ReadExcel();
        }

        protected Guid DepartmentID
        {
            get
            {
                if (!string.IsNullOrEmpty(Request["did"]))
                    return new Guid(Request["did"]);
                return Guid.Empty;
            }
        }
    }
}